/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package commands;
import IA.*; import java.util.*;
/**
 *
 * @author jmille80
 */
public class CmdGetFoodStatus extends Command {

    private int TableID;
    
    public CmdGetFoodStatus(InformationAggregator ia, int TableID) {
        super(ia);
        this.TableID = TableID;
    }
    
    @Override
    public String execute() {
        String retStr = "";
        if(ia.getKitchenQueue().TableInQueueOrGrill(TableID)) {
            retStr = "Cook Queue: " + ia.getKitchenQueue().getNumQueueItemsByTable(TableID) + " items";
            retStr += "\nCooking: " + ia.getKitchenQueue().getNumCookingItemsByTable(TableID) + " items";
            return retStr;
        }
        else {
            for(Iterator<Server> itr = ia.getServerCollection().getServerIterator(); itr.hasNext(); ) {
                Server s = itr.next();
                if(s.IsAssignedTo(TableID) && s.IsDeliveringFor(TableID)) {
                    return "Delivering Food...";
                }
            }
            return "Eating";
        }
    }
   
    
}
